#ifndef SSY_FTPGET_RULE_H
#define SSY_FTPGET_RULE_H


#define PATH_MAX 256
#define FTPRULE_MAX 32
#define SECTION_NUM 9

#define WILDC_YEAR4 "<YEAR4>"
#define WILDC_YEAR2 "<YEAR2>"
#define WILDC_MONTH "<MONTH>"
#define WILDC_MONTH2 "<MONTH2>"
#define WILDC_DAY "<DAY>"
#define WILDC_DAY2 "<DAY2>"
#define WILDC_24HOUR "<24HOUR>"
#define WILDC_24HOUR2 "<24HOUR2>"
#define WILDC_12HOUR "<12HOUR>"
#define WILDC_12HOUR2 "<12HOUR2>"
#define WILDC_MINUTE "<MINUTE>"
#define WILDC_MINUTE2 "<MINUTE2>"
#define WILDC_SECOND "<SECOND>"
#define WILDC_SECOND2 "<SECOND2>"
#define WILDC_MSECOND "<MSECOND>"
#define WILDC_MSECOND3 "<MSECOND3>"
#define WILDC_HPHM "<HPHM>"
#define WILDC_HPYS "<HPYS>"
#define WILDC_LANE1 "<LANE1>"
#define WILDC_LANE2 "<LANE2>"
#define WILDC_LOCATION "<LOCATION>"

typedef struct {
	char year4[8];
	char year2[4];
	char month[4];
	char month2[4];
	char day[4];
	char day2[4];
	char hour24[4];
	char hour242[4];
	char hour12[4];
	char hour122[4];
	char minute[4];
	char minute2[4];
	char second[4];
	char second2[4];
	char msecond[4];
	char msecond3[4];
	char hphm[16];
	char hpys[8];
	char lane1[4];
	char lane2[4];
	char location[128];
} t_WildSection;

typedef struct {
	int usedflag;
	char ip[16];
	int port;
	char username[16];
	char passwd[16];
	char dir[PATH_MAX];
	char name[PATH_MAX];
	char location[PATH_MAX];
	int lane;
} t_FtpRule;

typedef struct {
	t_FtpRule ftprule[FTPRULE_MAX];
	int ftprule_num;
} t_FtpRuleArray;

#ifdef __cplusplus
extern "C" {
#endif

	void FtpRule_SetWildSection(const char *path, const char *wildpath, t_WildSection *wildSection);
	void FtpRule_SetWildTime(const char *strtime, const char *strfmt, t_WildSection *wildSection);
	int FtpRule_ParseWildPath(char *outpath, int outsize, const t_WildSection *wildSection, const char *instr);
	int FtpRule_Read(const char *confPath, t_FtpRuleArray *ftpRuleArray);
	void FtpRule_Print(const t_FtpRuleArray *ftpRuleArray);

#ifdef __cplusplus
};
#endif


#endif // SSY_FTPGET_RULE_H

